package master;

/**
 * @author lakersUp
 * @Classname       整数反转
 * @Description     用异常解决
 * @Date 2022/3/31 10:41
 * @Version 1.0
 */
public class M7reverse {
    public int reverse(int x) {
        String string = Integer.toString(x);
        int flag=1;
        if(x<0){
            flag=-1;
            string=string.substring(1);
        }
        try{
            return Integer.valueOf(new StringBuffer(string).reverse().toString())*flag;
        }catch (Exception e){
            return 0;
        }

    }
}
